﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Se7en.Admin.Common;

namespace Se7en.Admin.Web.Controls
{
    public partial class Menu : UserControlBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                LoadMenu();
        }

        protected void menuHeader_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e)
        {
            if (e.Item != null && string.IsNullOrEmpty(e.Item.NavigateUrl))
                e.Item.Attributes.Add("onclick", "javascript:void(0);return false;");
        }

        private void LoadMenu()
        {
            if (this.AdminPage != null)
            {
                menuHeader.DataTextField = "Title";
                menuHeader.DataNavigateUrlField = "Url";
                menuHeader.DataFieldID = "MenuId";
                menuHeader.DataFieldParentID = "ParentId";
                menuHeader.DataValueField = "MenuId";
                menuHeader.DataSource = this.AdminPage.Menus;
                menuHeader.DataBind();
            }

        }
    }
}